package com.stox.model;


public class Scrip extends AbstractModel {
	private static final long serialVersionUID = 1L;

	public static enum ScripType{
		EQUITY,
		FNO,
		INDEX,
		COMMODITY;
	}
	
	private String id;
	
	private String isin;

	private String exchangeCode;
	
	private String industryCode;
	
	private ScripType scripType;
	
	public Scrip() {

	}

	public Scrip(String exchangeCode, String text) {
		String[] tokens = text.split(",");
		setCode(tokens[0]);
		setId(tokens[1]);
		setName(tokens[1]);
		/*setIsin(tokens[0]);
		setCode(tokens[1]);
		setId(tokens[2]);
		setName(tokens[3]);
		setIndustryCode(tokens[4]);*/
		setScripType(ScripType.EQUITY);
		setExchangeCode(exchangeCode);
	}

	@Override
	public String toString() {
		return getIsin()+","+getCode()+","+getId()+ "," + getName()+","+getIndustryCode();
	}

	public String getExchangeCode() {
		return exchangeCode;
	}

	public void setExchangeCode(String exchangeCode) {
		this.exchangeCode = exchangeCode;
	}

	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public String getIsin() {
		return isin;
	}

	public void setIsin(String isin) {
		this.isin = isin;
	}
	
	public String getIndustryCode() {
		return industryCode;
	}

	public void setIndustryCode(String industryCode) {
		this.industryCode = industryCode;
	}

	public ScripType getScripType() {
		return scripType;
	}

	public void setScripType(ScripType scripType) {
		this.scripType = scripType;
	}
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = super.hashCode();
		result = prime * result
				+ ((exchangeCode == null) ? 0 : exchangeCode.hashCode());
		result = prime * result + ((id == null) ? 0 : id.hashCode());
		result = prime * result + ((isin == null) ? 0 : isin.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (!super.equals(obj))
			return false;
		if (getClass() != obj.getClass())
			return false;
		Scrip other = (Scrip) obj;
		if (exchangeCode == null) {
			if (other.exchangeCode != null)
				return false;
		} else if (!exchangeCode.equals(other.exchangeCode))
			return false;
		if (id == null) {
			if (other.id != null)
				return false;
		} else if (!id.equals(other.id))
			return false;
		if (isin == null) {
			if (other.isin != null)
				return false;
		} else if (!isin.equals(other.isin))
			return false;
		return true;
	}

}
